Don't short circuit dep matching as soon as a name matches
authorJake Kerr <kodafox@gmail.com>
Sun, 5 Apr 2015 12:39:51 +0000 (21:39 +0900)
committerMohd Tarmizi <mohtar@users.noreply.github.com>
Tue, 14 Apr 2015 07:46:06 +0000 (15:46 +0800)
src/cargo/ops/cargo_rustc/context.rs

index 80f023bdf62d556f6496f7be2f0590890aa0ecfe..c7cfbfe775177cbe3699d8820c6b070843331104 100644 (file)
@@ -339,22 +339,22 @@ impl<'a, 'b: 'a> Context<'a, 'b> {
         };
         let mut ret = deps.map(|id| self.get_package(id)).filter(|dep| {
             let pkg_dep = pkg.dependencies().iter().find(|d| {
-                d.name() == dep.name()
-            }).unwrap();
-
-            // If this target is a build command, then we only want build
-            // dependencies, otherwise we want everything *other than* build
-            // dependencies.
-            let is_correct_dep = target.is_custom_build() == pkg_dep.is_build();
-
-            // If this dependency is *not* a transitive dependency, then it
-            // only applies to test/example targets
-            let is_actual_dep = pkg_dep.is_transitive() ||
-                                target.is_test() ||
-                                target.is_example() ||
-                                profile.test;
-
-            is_correct_dep && is_actual_dep
+                d.name() == dep.name() &&
+
+                // If this target is a build command, then we only want build
+                // dependencies, otherwise we want everything *other than* build
+                // dependencies.
+                target.is_custom_build() == d.is_build() &&
+
+                // If this dependency is *not* a transitive dependency, then it
+                // only applies to test/example targets
+                (d.is_transitive() ||
+                 target.is_test() ||
+                 target.is_example() ||
+                 profile.test)
+            });
+
+            pkg_dep.is_some()
         }).filter_map(|pkg| {
             pkg.targets().iter().find(|t| t.is_lib()).map(|t| {
                 (pkg, t, self.lib_profile(pkg.package_id()))